package dto

import (
	"tuowei.com/app/admin/models"
	common "tuowei.com/common/models"
)

type SysConfigCommissionUpdateReq struct {
	Id                              int     `json:"id" comment:"主键ID"`
	UserCommissionPer               float64 `json:"user_commission_per" gorm:"type:decimal(10,2);comment:普通用户返佣"`
	VipCommissionPercentage         float64 `json:"vip_commission_percentage" gorm:"type:decimal(10,2);comment:VIP用户返佣"`
	SVipCommissionPercentage        float64 `json:"svip_commission_percentage" gorm:"type:decimal(10,2);comment:SVIP用户返佣"`
	MinWithdraw                     float64 `json:"min_withdraw" gorm:"type:decimal(10,2);comment:最低提现"`
	CommissionWithdraw              float64 `json:"commission_withdraw" gorm:"type:decimal(10,4);comment:提现手续费"`
	UserCommissionPerSpecial        float64 `json:"user_commission_per_special" gorm:"type:decimal(10,2);comment:特别普通用户返佣"`
	VipCommissionPercentageSpecial  float64 `json:"vip_commission_percentage_special" gorm:"type:decimal(10,2);comment:特别VIP用户返佣"`
	SVipCommissionPercentageSpecial float64 `json:"svip_commission_percentage_special" gorm:"type:decimal(10,2);comment:特别SVIP用户返佣"`
	UserCommissionCourseId          string  `json:"user_commission_course_id" gorm:"varchar(5000);comment:普通用户关联"`
	VipCommissionCourseId           string  `json:"vip_commission_course_id" gorm:"varchar(5000);comment:VIP用户关联"`
	SVipCommissionCourseId          string  `json:"svip_commission_course_id" gorm:"varchar(5000);comment:特别SVIP用户关联"`
	common.ControlBy
}

func (s *SysConfigCommissionUpdateReq) Generate(model *models.SysConfigCommission) {
	if s.UserCommissionPer != 0.00 {
		model.UserCommissionPer = s.UserCommissionPer
	}
	if s.VipCommissionPercentage != 0.00 {
		model.VipCommissionPercentage = s.VipCommissionPercentage
	}
	if s.SVipCommissionPercentage != 0.00 {
		model.SVipCommissionPercentage = s.SVipCommissionPercentage
	}
	if s.MinWithdraw != 0.00 {
		model.MinWithdraw = s.MinWithdraw
	}
	if s.CommissionWithdraw != 0.00 {
		model.CommissionWithdraw = s.CommissionWithdraw
	}
	if s.UserCommissionPerSpecial != 0.00 {
		model.UserCommissionPerSpecial = s.UserCommissionPerSpecial
	}
	if s.VipCommissionPercentageSpecial != 0.00 {
		model.VipCommissionPercentageSpecial = s.VipCommissionPercentageSpecial
	}
	if s.SVipCommissionPercentageSpecial != 0.00 {
		model.SVipCommissionPercentageSpecial = s.SVipCommissionPercentageSpecial
	}
	if s.UserCommissionCourseId != "" {
		model.UserCommissionCourseId = s.UserCommissionCourseId
	}
	if s.VipCommissionCourseId != "" {
		model.VipCommissionCourseId = s.VipCommissionCourseId
	}
	if s.SVipCommissionCourseId != "" {
		model.SVipCommissionCourseId = s.SVipCommissionCourseId
	}
	model.CreateBy = s.CreateBy
}

func (s *SysConfigCommissionUpdateReq) GetId() interface{} {
	return s.Id
}
